import Cookies from 'js-cookie'

const TokenKey = 'slwl_token'
const UserInfo = 'slwl_user_info'
const UserRoutes = 'slwl_user_routes'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token, expires) {
  return Cookies.set(TokenKey, token, { expires })
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function getUserInfo() {
  return JSON.parse(localStorage.getItem(UserInfo))
}

export function setUserINfo(userInfo) {
  return localStorage.setItem(UserInfo, JSON.stringify(userInfo))
}

export function removeUserInfo() {
  return localStorage.removeItem(UserInfo)
}

export function getUserRoutes() {
  return JSON.parse(localStorage.getItem(UserRoutes))
}

export function setUserRoutes(userRoutes) {
  return localStorage.setItem(UserRoutes, JSON.stringify(userRoutes))
}

export function removeUserRoutes() {
  return localStorage.removeItem(UserRoutes)
}
